#include <stdio.h>

int main(void)
{       
        short int s1 = 0x1234;
        // 把&s1类型转换为char指针，取首字符
        char first_c = *((char*) &s1);
        // 如果首字符是0x34，则为小端，因为低位在前
        if (first_c == 0x34)
                printf("this is little endian\n");
        // 如果首字符是0x12，则为大端，因为高位在前
        else if (first_c == 0x12)
                printf("this is big endian\n");
        return 0;
}       
